package StructuralPattern.ProxyPattern.StaticProxy;

public class ProxyService implements Service{
    private RealService realService;

    @Override
    public void add() {
        if (realService == null) {
            realService = new RealService();
        }
//        System.out.println("在代理中,执行额外操作");
        realService.add();
        System.out.println("在代理中,记录日志，添加成功");
    }

    @Override
    public void del() {
        if (realService == null) {
            realService = new RealService();
        }
//        System.out.println("在代理中执行额外操作");
        realService.del();
        System.out.println("在代理中,记录日志，删除成功");
    }
}
